package com.wj.rpsm.user.mapper;

import com.wj.rpsm.user.pojo.Comment;
import com.wj.rpsm.user.pojo.vo.CommentVo;
import com.wj.rpsm.user.pojo.vo.ForumVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author WeiJin
 * @version 1.0
 */
@Repository
public interface CommentMapper {


    /**
     * 根据帖子id获取评论
     * @param messageId
     * @return
     */
    List<CommentVo> getParentComment(@Param("messageId")Integer messageId);

    /**
     * 新增回复
     * @param comment
     * @return
     */
    @Insert("insert into comment value (null,#{comment_content},#{comment_publish_time},#{comment_userid}," +
            "#{comment_parent_message_id},#{comment_parent_comment_id},0,0)")
    Integer addComment(Comment comment);

    /**
     * 获取子评论
     * @param commentId
     * @return
     */
    List<CommentVo> getChildComment(@Param("commentId") Integer commentId);

    /**
     * 评论点赞
     * @param commentId
     * @return
     */
    @Update("update comment set comment_like = comment_like + 1  where comment_id = #{commentId}")
    Integer updateCommentLike(Integer commentId);
    /**
     * 评论点赞
     * @param commentId
     * @return
     */
    @Update("update comment set comment_like = comment_unlike + 1  where comment_id = #{commentId}")
    Integer updateCommentUnlike(Integer commentId);

}
